<?php

namespace App\Traits;


use App\Common\SysContext;
use App\X\XDataBase;
use App\X\XContext;

trait TraitConnectDB
{
    /**
     * @return \App\Common\DB\CommonMysql
     * @throws \Exception
     */
    public function db()
    {
        return SysContext::funcInsStatic()->db();
    }

    /**
     * @return \App\Common\DB\CommonRedis
     * @throws \Exception
     */
    public function redis()
    {
        return SysContext::funcInsStatic()->redis();
    }

    /**
     * @return \App\Common\DB\CommonRedis
     * @throws \Exception
     */
    public function redis6380()
    {
        $context = SysContext::funcInsStatic();

        $db = $context->get(\App\Common\DB\Pool\PoolRedis_6380::class);
        if ($db === null)
        {
            $app_db = new XDataBase(\App\Common\DB\Pool\PoolRedis_6380::class);

            $db = $app_db->funcGetDB();
        }


        return $db;
    }

}